<html>
	<head>
	<style>
	body {
		font-size: 12px;
	}
	table.haho{
		border: 1px solid black;
		font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;
		color:#000;
	}
	table.haho td{
		border: 1px solid black;
	}
	table.haho tr{
		border: 1px solid black;
	}
	table.haho th{
		border: 1px solid black;

	}
	
	table.peserta{
		border: 1px solid black;
		font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;
		color:#000;
	}
	table.peserta td{
		border: 1px solid black;
		text-align: center;
	}
	table.peserta tr{
		border: 1px solid black;
	}
	table.peserta th{
		border: 1px solid black;

	}
	
	table {
		width: 100%;
	}
	table.kosong {
		border:none;
		font:29px Arial, Helvetica, sans-serif;	
	}
	.title {
		font-family:"Calibri Light", sans-serif;
		font-size: 18px;
		color:#1BA1E2;
		margin-top:10px;
		margin-bottom:5px;
	}
	.judul
	{
		font-family:"Calibri-Light", "Calibri Light", sans-serif;
		font-size: 28px;
		margin-top:10px;
		margin-bottom:20px;
		text-align: center;
	}
	div {
		text-align: justify;
		text-justify: inter-word;
		width: 100%;
		font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;
	}
	</style>
	</head>
	<title>Final Report</title>

    <body>
	
		<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" class="kosong">
	  <tr>
	    <td width="50%"><img src="<?php echo base_url()?>assets/img/logoCFIsmall.jpg" width="145" height="100"></td>
	    <td align="right"><img src="<?php echo base_url()?>assets/img/logoPerpusSmall.jpg" width="241" height="100"></td>
      </tr>
    </table>
	<div class="judul">Laporan Kegiatan</div>
<!--	<p align="left"> -->
		<div class="title">IDENTITAS LAPORAN</div>
		
		<!-- Tabel Identitas Laporan-->
		<table border="1" cellpadding="5" cellspacing="0"  class="haho" > 
			<tr>
				<td width="25%">Provinsi </td>
				<td colspan="3"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi()->getNama();?>&nbsp;</td>
			</tr>
			<tr>
				<td>Kab/Kota </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getNama();?></td>
			</tr>
			<tr>
				<td>Desa </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa() != null) echo $berkas->getPerpustakaan()->getDesa()->getNama();?></td>
			</tr>
			<tr>
				<td>Nama Perpustakaan </td>
				<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan() != null) echo $berkas->getPerpustakaan()->getNama();?></td>
			</tr>
			<tr>
				<td>Jenis Laporan</td>
				<td colspan="3" style="width:70%"><?php echo $berkas->getTipe()->getNama();?></td>
			</tr>
			<tr>
				<td>Rincian Laporan</td>
				<td colspan="3 style="width:70%""><?php if ($berkasTraining != null) 
															echo $berkasTraining->getJenisTraining()->getNama();
															
													?>&nbsp;</td>
			</tr>
			<?php
			$fromDate = "-";
			$toDate = "-";
			
			if ($berkasTraining != NULL){
				if ($berkasTraining->getFromDate() != NULL){
					$fromDate = $berkasTraining->getFromDate()->format('d-m-Y');						
				} else {
					$fromDate = "-";					
				}
				
				if ($berkasTraining->getToDate() != NULL){
					$toDate = $berkasTraining->getToDate()->format('d-m-Y');	
				} else {
					$toDate = "-";
				}
				
			} else if ($berkasLkpm != NULL) {
				if ($berkasLkpm->getFromDate() != NULL){
					$fromDate = $berkasLkpm->getFromDate()->format('d-m-Y');
					
				} else {
					$fromDate = "-";					
				}
				
				if ($berkasLkpm->getToDate() != NULL){
					$toDate = $berkasLkpm->getToDate()->format('d-m-Y');
				} else {
					$toDate = "-";
				}	
			} else if ($berkasLas != NULL){
				if ($berkasLas->getFromDate() != NULL){
					$fromDate = $berkasLas->getFromDate()->format('d-m-Y');					
				}
				if ($berkasLas->getToDate() != NULL){
					$toDate = $berkasLas->getToDate()->format('d-m-Y');
				} 	
			}
			?>
			<tr>
				<td>Tanggal Kegiatan Dimulai </td>
				<td style="text-align:center"><?php echo $fromDate?></td>
				<td >Tanggal Kegiatan Selesai : </td>
				<td style="text-align:center"><?php echo $toDate?></td>
			</tr>
		</table>
		<br>
		
		<?php if ($berkasLkpm != null) { ?>
			<!-- Table Jenis Kegiatan-->
			<table border="1" cellpadding="5" cellspacing="0" align="center" class="haho">
				<tr>
					<td width="25%">Jenis Kegiatan : </td>
					<td colspan="2"><?php if ($berkasLkpm != null && $berkasLkpm->getJenisKegiatan() != NULL) echo $berkasLkpm->getJenisKegiatan()->getNama()?>&nbsp; </td>

				</tr>
				
				<tr>
					<td width="25%">Topik Kegiatan : </td>
					<td colspan="2"><?php if ($berkasLkpm != null && $berkasLkpm->getTopikKegiatan() != NULL) echo $berkasLkpm->getTopikKegiatan()->getNama()?>&nbsp; </td>
				</tr>
				
				<tr>
					<td >Kelompok Sasaran :  </td>
					
				<?php 
				  $criteria = array('berkas' => $berkas);
				  $berkasLkpmSasarans = $this -> em -> getRepository('\models\entities\BerkasLkpmSasaran')->findBy($criteria);	
				  if (is_array($berkasLkpmSasarans) && count($berkasLkpmSasarans) > 0){
					  $i = 0;
					  foreach ($berkasLkpmSasarans as $row){
					  		if ($i == 0){
					  			echo '<td style="width:70%" colspan="2">'.$row->getKelompokSasaran()->getNama().'</td>
									</tr>';											
					  		}  else {
					  			echo '<tr>
										<td>&nbsp;</td>
										<td style="width:70%" colspan="2">'.$row->getKelompokSasaran()->getNama().'</td>
									</tr>';		
					  		}
							$i++;
					  }  	
				  }
				?>
		</table>
		<?php } ?>
		<br>
		
		<!-- Table Jenis Asistensi-->
		<?php if ($berkasLas != null) { ?>
		<table border="1" cellpadding="5" cellspacing="0" align="center" class="haho"> 
			<tr>
				<td width="25%">Jenis Asistensi </td>
				<td colspan="2" style="width:70%"><?php if ($berkasLas != NULL){
															if ($berkasLas->getJenisAsistensi() == 1){
																$jenisAsistensi = "Non Kunjungan";
															} else {
																$jenisAsistensi = "Kunjungan";
															}
															echo $jenisAsistensi;
														}
													?>&nbsp; </td>
			</tr>
			<tr>
				<td >Media Asistensi</td>
				<!--<td>&#10003;</td>-->
				<td colspan="2" style="width:70%"><?php echo $berkasLas->getMedia()->getNama()?></td>
			</tr>
			<tr>
				<td >Kategori Asistensi</td>
				<!--<td>&#10003;</td> -->
				<td colspan="2" style="width:70%"><?php echo $berkasLas->getKategoriAsistensi()->getNama()?></td>
			</tr>
		<!--	<tr>
				<td>&#10003;</td>
				<td style="width:70%">Partisipasi Kegiatan</td>
			</tr>
			<tr>
				<td>&#10003;</td>
				<td style="width:70%">TIK</td>
			</tr>
			<tr>
				<td>&#10003;</td>
				<td style="width:70%">Community Engagement</td>
			</tr>
			<tr>
				<td>&#10003;</td>
				<td style="width:70%">Advokasi dan Kemitraan</td>
			</tr> -->
		</table>
		<?php } ?>
		<br>

	<p align="left">
		<?php if ($berkasTraining != null) { ?>
		<div class="title">JUMLAH PESERTA</div>
		<!-- Tabel Jumlah Peserta -->
		<?php
				$stafLaki = 0;
				$stafPr = 0;
				$nonstafLaki = 0;
				$nonstafPr = 0;
				$lainnya = 0;
				foreach ($memberOfTraining as $row){
					if ($row->getStaff() == "S"){
						if ($row->getGender() == "M"){
							$stafLaki++;
						} else if ($row->getGender()=="F"){
							$stafPr++;
						} 
					} else if ($row->getStaff() == "N") {
						if ($row->getGender() == "M"){
							$nonstafLaki++;
						} else if ($row->getGender()=="F"){
							$nonstafPr++;
						}
					} else {
						$lainnya++;
					}																				
				}  
				
				$laki = $stafLaki + $nonstafLaki;
				$pr = $stafPr + $nonstafPr;
				$total = $laki + $pr;
				if ($stafLaki <= 0){
					$stafLaki = "-";
				}
				
				if ($stafPr <= 0){
					$stafPr = "-";
				}
				
				if ($nonstafLaki <= 0){
					$nonstafLaki = "-";
				}
				
				if ($nonstafPr <= 0){
					$nonstafPr = "-";
				}
				
				if ($laki <= 0){
					$laki = "-";
				}
				
				if ($pr <= 0){
					$pr = "-";
				}
				
				if ($total <= 0){
					$total = "-";
				}
				
				if ($lainnya <= 0){
					$lainnya = "-";
				}
			?>
		<table border="1" cellpadding="5" cellspacing="0" class="peserta"> 
			<tr>
				<td colspan="2">Staf Perpustakaan</td>
				<td colspan="2">Non-Staf Perpustakaan</td>
				<td colspan="3">Total</td>
				<td rowspan="2">Lainnya</td>
			</tr> 
			<tr>
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Laki - Laki</td>
				<td>Perempuan</td>			
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Total</td>
			</tr>
			<tr>
				<td><?php echo $stafLaki?></td>
				<td><?php echo $stafPr?></td>
				<td><?php echo $nonstafLaki?></td>
				<td><?php echo $nonstafPr?></td>			
				<td><?php echo $laki?></td>
				<td><?php echo $pr?></td>
				<td><?php echo $total?></td>
				<td><?php echo $lainnya?></td>
			</tr> 
		</table>
		<br>
		<?php } ?>
		<div class="title">GAMBARAN KEGIATAN</div>
		<div>
			<?php
				echo $berkas->getDescription();
		?>
		</div>
		<br>
		<div class="title">HASIL KEGIATAN</div>
		<div>
			<?php
				echo $berkas->getHasilKegiatan();
		?>
		</div>
		<br>
		<div class="title">TANTANGAN KEGIATAN</div>
		<div>
		<?php
				echo $berkas->getTantangan();
		?>
		</div>
		<br>
		<div class="title">LAMPIRAN</div>
		<div>
		<ol>
			<?php
				if (is_array($berkasAttachments) && count($berkasAttachments) > 0){
					//die('test');
					foreach ($berkasAttachments as $row){
						echo '<li>'.basename($row->getPath()).'</li>';
					}
				}
				//die();
			?>	
		</ol>  
		</div>
		<br>
		<div class="title">CATATAN TAMBAHAN</div>
		<table border="1" cellpadding="5" cellspacing="0" class="haho"> 
			<tr>
				<td>Tanggal Laporan Dibuat:</td>
				<td><?php echo $berkas->getStartDate()->format('d-m-Y H:i:s');?></td>
				<td>Tanggal Laporan Dikirimkan:</td>
				<td><?php if ($berkasTerkirim !=NULL) echo $berkasTerkirim['createdDate']?></td>
			</tr> 
			<tr>
				<td>Tanggal Laporan Selesai Direview:</td>
				<td><?php if ($berkasTerkirim !=NULL) echo $berkasTereview['createdDate']?></td>
				<td>Tanggal Laporan Disetujui:</td>
				<td><?php echo $berkas->getEndDate()->format('d-m-Y H:i:s'); ?></td>
			</tr>
		</table>
	</p>
	</body>
</html>